var t = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../dist/dialog/dialog")), e = getApp();

Page({
    data: {
        active: 0,
        enterprise_list: [],
        enterprise_current_page: 1,
        enterprise_last_page: 1,
        server_list: [],
        server_list_current_page: 1,
        server_list_last_page: 1
    },
    onLoad: function(t) {},
    edit: function(t) {
        var e = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageI/lawyerPlatform/enterprise/add/add?type=edit&id=" + e
        });
    },
    getData: function() {
        var t = this, a = "";
        a = 0 == this.data.active ? "plugin.lawyer-platform.frontend.controllers.business.getBusiness" : "plugin.lawyer-platform.frontend.controllers.diy-form.getList", 
        e._postNetWork({
            url: e.getNetAddresss(a),
            success: function(a) {
                1 == a.data.result ? 0 == t.data.active ? t.setData({
                    enterprise_list: a.data.data.list.data,
                    enterprise_last_page: a.data.data.list.last_page
                }) : t.setData({
                    server_list: a.data.data.list.data,
                    server_list_last_page: a.data.data.list.last_page
                }) : e.tips(a.data.msg);
            }
        });
    },
    to: function(t) {
        var e = t.currentTarget.dataset.id, a = t.currentTarget.dataset.dataid;
        wx.navigateTo({
            url: "/packageI/enterprise/enterprise_form?id=" + e + "&dataId=".concat(a)
        });
    },
    onChange: function(t) {
        this.setData({
            active: t.detail.index
        }), 1 == this.data.active && this.getData();
    },
    handle: function() {
        wx.navigateTo({
            url: "/packageI/lawyerPlatform/enterprise/add/add?type=add"
        });
    },
    del_enterprise: function(a) {
        var r = this, s = a.currentTarget.dataset.id;
        t.default.alert({
            title: "提示",
            message: "是否删除该企业"
        }).then(function() {
            e._postNetWork({
                url: e.getNetAddresss("plugin.lawyer-platform.frontend.controllers.business.delete"),
                data: {
                    id: s
                },
                success: function(t) {
                    1 == t.data.result ? (e.tips(t.data.msg), r.getData()) : e.tios(t.data.msg);
                }
            });
        });
    },
    onShow: function() {
        this.getData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.getMoreData();
    },
    getMoreData: function() {
        var t = this;
        if (!(this.data.enterprise_current_page >= this.data.enterprise_last_page)) {
            var a = this.data.enterprise_current_page + 1;
            e._postNetWork({
                url: e.getNetAddresss("plugin.lawyer-platform.frontend.controllers.business.getBusiness"),
                data: {
                    page: a
                },
                success: function(a) {
                    if (1 == a.data.result) {
                        var r = t.data.enterprise_list.concat(a.data.data.list.data);
                        console.log(r), t.setData({
                            enterprise_current_page: a.data.data.list.current_page,
                            enterprise_last_page: a.data.data.list.last_page,
                            enterprise_list: r
                        });
                    } else e.tips(a.data.msg);
                }
            });
        }
    },
    onShareAppMessage: function() {}
});